<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Mon panier"/>
        </ui:define>
        <ui:define name="body">
            
            <h:form>
                <c:choose>
                    <c:when test="${empty sessionScope.mbCart.cartItems}">
                        Le panier est vide
                    </c:when>
                    <c:otherwise> 
                        <h:dataTable value="#{mbCart.cartItems}" var="cartItem" border="1">
                            <f:facet name="header">
                                <h:outputText value="détail de votre panier" />
                            </f:facet>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Couverture du livre" />
                                </f:facet>
                                <h:outputText value="#{cartItem.item.bitmapURL}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Titre du livre" />
                                </f:facet>
                                <h:outputText value="#{cartItem.item.title}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Quantité" />
                                </f:facet>
                                <h:outputText id="quantityInput" value="#{cartItem.quantity}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Price" />
                                </f:facet>
                                <h:outputText id="prixTotal" value="#{cartItem.subTotal} €" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="boutons"/>
                                </f:facet>
                                <h:commandLink value="Supprimer" action="#{mbCart.removeItem()}">
                                    <f:param name="isbn" value="#{cartItem.item.isbn}"/>
                                </h:commandLink>
                            </h:column>
                             <h:column>
                              
                                 <h:commandLink value="Modifier" action="#">
                                    <f:param name="isbn" value="#{cartItem.item.isbn}"/>
                                </h:commandLink>
                            </h:column>
                            <f:facet name="footer">
                                <h:outputText value="Total: #{mbCart.total} €" />
                            </f:facet>
                            <f:facet name="footer">
                                <h:outputText value="nbArticles: #{mbCart.itemNumber}"/>
                            </f:facet>
                        </h:dataTable>
                            <div>
                                <h:commandButton value="Valider panier" />
                                <h:commandButton value="retour" onclick="#{mbCart.checkout()}" />
                            </div>
                    </c:otherwise>
                </c:choose>
            </h:form>  
        </ui:define>
    </ui:composition>
</html>

